package com.ljf.admin.exception;

import com.ljf.framework.result.JsonResultEnum;

/**
 * @Auther: lijinfeng
 * @Date: 2022/4/20
 * @Description 描述: system模块自定义异常
 */
public class LjfSystemException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     *
     * 和 {@link CommonResult#getDetailMessage()} 一致的设计
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public LjfSystemException()
    {
    }

    public LjfSystemException(String message)
    {
        this.message = message;
    }

    public LjfSystemException(String message, Integer code)
    {
        this.message = message;
        this.code = code;
    }

    public LjfSystemException(JsonResultEnum resultEnum) {
        this.code = Integer.valueOf(resultEnum.getCode());
        this.message = resultEnum.getMessage();
    }

    public String getDetailMessage()
    {
        return detailMessage;
    }

    public String getMessage()
    {
        return message;
    }

    public Integer getCode()
    {
        return code;
    }

    public LjfSystemException setMessage(String message)
    {
        this.message = message;
        return this;
    }

    public LjfSystemException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }
}
